import { Course } from '../model/Course.js'

const fn_list = async (ctx, next) => {
    const course = await Course.findAll()
    ctx.body = {
        code: 1000,
        msg: '获取图书列表成功',
        data: course
    }
}

const fn_getById = async (ctx, next) => {
    //获取url的id
    const id = ctx.params.id
    //去数据库查询
    const course = await Course.findByPk(id)
    console.log(course);

    ctx.body = {
        code: 1000,
        msg: '成功',
        data: course
    }
}

export default [
    {
        method: 'get',
        url: '/course',
        fn: fn_list
    },
    {
        method: 'get',
        url: '/course/:id',
        fn: fn_getById
    }
]